//
//  UserModel.m
//  iOSMobile
//
//  Created by QingSong_Hao on 17/7/3.
//  Copyright © 2017年 PCITC. All rights reserved.
//

#import "UserModel.h"

@implementation UserModel

/**
 取出对象时候调用

 @param decoder decoder
 @return 对象信息
 */
- (id)initWithCoder:(NSCoder *)decoder{
    if (self = [super init]) {
        self.userId = [decoder decodeObjectForKey:@"userId"];
        self.phone = [decoder decodeObjectForKey:@"userPhone"];
        self.username = [decoder decodeObjectForKey:@"userName"];
        self.shopName = [decoder decodeObjectForKey:@"shopName"];
        self.portrait = [decoder decodeObjectForKey:@"portrait"];
        self.position = [decoder decodeObjectForKey:@"position"];
    }
    return self;
}

/**
 存入对象时调用

 @param encoder encoder
 */
- (void)encodeWithCoder:(NSCoder *)encoder{
    [encoder encodeObject:self.username forKey:@"userName"];
    [encoder encodeObject:self.phone forKey:@"userPhone"];
    [encoder encodeObject:self.shopName forKey:@"shopName"];
    [encoder encodeObject:self.portrait forKey:@"portrait"];
    [encoder encodeObject:self.position forKey:@"position"];
    if (_login) {
        [encoder encodeObject:self.userId forKey:@"userId"];
    }else{
        [encoder encodeObject:@""  forKey:@"userId"];
    }
}

-(BOOL)isLogin{
    if ([self.userId integerValue] == 0) {
        _login = NO;
    }else{
        _login = YES;
    }
    return _login;
}

@end
